/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package exercicio.lista1;

import java.util.Random;

/**
 *
 * @author afonso
 */
public class Questao3 {

    public static void main(String[] args) {
        int nExp = 100000;
        int num = 200;
        double p = 0.02;
        int evento = 0;
        Random r = new Random(System.currentTimeMillis());
        for (int i = 0; i < nExp; i++) {
            for (int j = 0; j < num; j++) {
                if(r.nextDouble() <= 0.02) evento++;
           }
        }
        double prob = (double) evento / nExp;
        System.out.println("Probabilidade: " + prob);
    }

}
